//
//  BKFeaturedTableViewCell.m
//  bestkeep
//
//  Created by yons on 16/11/29.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKFeaturedTableViewCell.h"
#import "UIButton+XN.h"

@implementation BKFeaturedTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initViews];
    }
    return self;
}


-(void)initViews{
    _goodsImageView = [UIImageView new];
    [self addSubview:_goodsImageView];
    [_goodsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(20);
        make.top.mas_equalTo(self.mas_top).offset(20);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-20);
        make.width.mas_equalTo(self.goodsImageView.mas_height);
    }];
    
    _titleLabel = [UILabel new];
    _titleLabel.font = [Common systemFontOfSize:14];
    _titleLabel.textColor = RGBACOLOR(64, 64, 64, 1);
    _titleLabel.numberOfLines = 2;
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.goodsImageView.mas_right).offset(11);
        make.top.mas_equalTo(self.mas_top).offset(12);
        make.right.mas_equalTo(self.mas_right).offset(-10);
    }];
    
    _desLabel = [UILabel new];
    _desLabel.font = [Common systemFontOfSize:12];
    _desLabel.textColor = RGBACOLOR(102, 102, 102, 1);
    _desLabel.numberOfLines = 2;
    [self addSubview:_desLabel];
    [_desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.goodsImageView.mas_right).offset(11);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-10);
    }];
    
    _marketLabel = [UILabel new];
    _marketLabel.text = @"市场价：";
    _marketLabel.textColor = RGBACOLOR(102, 102, 102, 1);
    _marketLabel.font = [UIFont systemFontOfSize:11];
    [self addSubview:_marketLabel];
    [_marketLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom).offset(-12);
        make.left.equalTo(self.goodsImageView.mas_right).offset(11);
        make.width.equalTo(@50);
    }];
    
    _marketPriceLabel = [BKMain_StrikeLabel new];
    _marketPriceLabel.font = [Common systemFontOfSize:12];
    _marketPriceLabel.textColor = RGBACOLOR(102, 102, 102, 1);
    _marketPriceLabel.strikeThroughColor = RGBACOLOR(102, 102, 102, 1);
    _marketPriceLabel.strikeThroughEnabled = YES;
    _marketPriceLabel.strkeLineStyle = StrikeLineStyleMiddle;
    [self addSubview:_marketPriceLabel];
    [_marketPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.marketLabel.mas_right).offset(-3);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-12);
        make.right.mas_equalTo(self.mas_right).offset(-10);
    }];
    
    _VIPImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BKFeatured_VIP"]];
    [self addSubview:_VIPImageView];
    [_VIPImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.goodsImageView.mas_right).offset(11);
        make.width.equalTo(@30);
        make.height.equalTo(@15);
        make.bottom.mas_equalTo(self.marketPriceLabel.mas_top).offset(-3);
    }];
    
    _goodsPriceLabel = [UILabel new];
    _goodsPriceLabel.font = [Common systemFontOfSize:16];
    _goodsPriceLabel.textColor = RGBACOLOR(230, 62, 46, 1);
    [self addSubview:_goodsPriceLabel];
    [_goodsPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.VIPImageView.mas_right).offset(2);
        make.height.equalTo(@21);
        make.centerY.mas_equalTo(self.VIPImageView.mas_centerY);
    }];
    
    _lookButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_lookButton setTitle:@"立即查看" forState:UIControlStateNormal];
    _lookButton.titleLabel.font = [Common systemFontOfSize:13];
    [_lookButton setImage:[UIImage imageNamed:@"BKFeatured_greenArrowR"] forState:UIControlStateNormal];
    [_lookButton setTitleColor:RGBACOLOR(0, 186, 156, 1) forState:UIControlStateNormal];
    [self addSubview:_lookButton];
    [_lookButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@26.5);
        make.right.equalTo(self.mas_right).offset(-10);
        make.bottom.equalTo(self.mas_bottom).offset(-11);
        make.width.equalTo(@74.5);
    }];
    [_lookButton layoutButtonWithEdgeInsetsStyle:XNButtonEdgeInsetsStyleRight imageTitleSpace:4];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
